package com.ytjj.qmyx.users.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.api.ResultCode;
import com.ytjj.common.controller.BaseController;
import com.ytjj.common.utils.TokenUtil;
import com.ytjj.qmyx.users.model.response.H5SignResponse;
import com.ytjj.qmyx.users.service.UsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * h5 签到控制
 *
 *
 * @version 1.0
 *
 */
@RestController
@RequestMapping("/h5Sign")
@Slf4j
public class H5SignController extends BaseController {

    @Autowired
    private UsersService usersService;

    /**
     * h5签到列表
     *
     * @return
     */
    @RequestMapping("/getH5SignList")
    public CommonResult getH5SignList(){
        H5SignResponse h5SignResponse = usersService.getH5SignInfo(TokenUtil.getToken());
        return CommonResult.success(h5SignResponse);
    }

    /**
     * h5 签到
     * @return
     */
    @RequestMapping("/h5ToSign")
    public CommonResult h5ToSign(){
        com.ytjj.common.model.UsersResponse usersResponse = this.getH5CurrentUser();
        usersService.h5ToSign(usersResponse);
        return CommonResult.success(50);
    }


    /**
     * XXXX优品 签到
     * @return
     */
    @RequestMapping("/GUOBh5ToSign")
    public CommonResult GUOBh5ToSign(@RequestParam(required = false) String signTime){
        com.ytjj.common.model.UsersResponse usersResponse = this.getH5CurrentUser();
        usersService.GUOBh5ToSign(usersResponse,signTime);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * h5签到列表
     *
     * @return
     */
    @RequestMapping("/getGUOBH5SignList")
    public CommonResult getGUOBH5SignList(){
        H5SignResponse h5SignResponse = usersService.getGUOBH5SignList(TokenUtil.getToken());
        return CommonResult.success(h5SignResponse);
    }
}
